package com.itheima.Demo2;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Stream;

public class StreamDemo {
    public static void main(String[] args) {
//        method();
//        method2();
//        method3();
//        method4();
    }

    private static void method4() {
        Stream.of(1,2,3,4,5,6,7).forEach(s -> System.out.println(s));
    }

    private static void method3() {
        int[] arr = {1,2,3,4,5};
        Arrays.stream(arr).forEach(s -> System.out.println(s));
    }

    private static void method2() {
        HashMap<String,Integer> list = new HashMap<>();

        list.put("张三",23);
        list.put("李四",24);
        list.put("王五",25);
        list.keySet().stream().forEach( (s) ->{
                    System.out.println(s);
        });

        list.entrySet().stream().forEach((s) -> {
            System.out.println(s);
        });
    }


    private static void method() {
        ArrayList<String> li = new ArrayList<>();

        li.add("张三");
        li.add("李四");
        li.add("王五");

//        Stream<String> stream = li.stream();
//        stream.forEach(s -> System.out.println(s));

        li.stream().forEach(s -> System.out.println(s));
    }
}
